import { observable, action, toJS } from 'mobx';
import { Toast, WhiteSpace, WingBlank, Button, ListView, Tools } from 'weaver-mobile';
import * as Apis from '../../api/remind'
import { ListViewPage, RouteLayout, Reply, SearchAdvanced } from 'weaver-mobile-page';
import { Form } from 'weaver-mobile-page';
const getLabel = Tools.getLabel;
export default class RemindStore {
    comObj = {};
    params = {};
    @observable list = {};
    @observable contactLogLayout = {};
    @observable addRemindLayout = {};
    @observable sellChanceCardLayout = {};
    @observable hrmCardLayout = {};
    @observable showHead = true;
    @observable chanceListLayout = {}
    @observable customerCardLayout = {}
    @observable contacterCardLayout = {}
    @observable tabs = [
        {
            title: getLabel('332', '全部'),
            key: "all"
        },
        {
            title: getLabel('84239', '系统提醒'),
            key: "system"
        },
        {
            title: getLabel('127015', '我发出的'),
            key: "mySend"
        },
        {
            title: getLabel('514777', '我收到的'),
            key: "myReceive"
        },
    ];
    @observable tabKey = "all";
    @action
    doNew = (comObj, params) => {
        this.comObj = comObj;
        this.params = params;
        // console.log(comObj.props)
        if (typeof (comObj.props.showHead) != "undefined" && !comObj.props.showHead) {
            this.showHead = comObj.props.showHead;
            // console.log(this.showHead)
        }
        if (params && params.defaultTab) {
            this.tabKey = params.defaultTab;
        }
        // this.tabKey = params.defaultTab ? params.defaultTab : "all";
        const currentPath = comObj.props.location.pathname;
        this.doInIt();
        this.contactLogLayout = new RouteLayout.Store({ route: currentPath, id: 'contactLogLayout' });
        this.addRemindLayout = new RouteLayout.Store({ route: currentPath, id: 'addRemindLayout' });
        this.sellChanceCardLayout = new RouteLayout.Store({ route: currentPath, id: 'sellChanceCardLayout' });
        this.chanceListLayout = new RouteLayout.Store({ route: currentPath, id: 'chanceListLayout' });
        this.hrmCardLayout = new RouteLayout.Store({ route: currentPath, id: 'hrmCardLayout' });
        this.customerCardLayout = new RouteLayout.Store({ route: currentPath, id: 'customerCardLayout' });
        this.contacterCardLayout = new RouteLayout.Store({ route: currentPath, id: 'contacterCardLayout' });
    }

    @action
    doInIt = () => {
        const currentPath = this.comObj.props.location.pathname;
        let params = { tabKey: this.tabKey, ...this.params }
        this.list = new ListViewPage.Store({ route: currentPath });
        Apis.getRemindListPage(params).then(data => {
            if (data.status == "success") {
                const dataKey = data.datas;
                this.list.getData({ dataKey });
            }
        });
    }
    @action
    deleteRemind = (params) => {
        Apis.deleteRemind(params).then(data => {
            this.doInIt();
        });
    }
    @action
    updateTabKey = (tabKey) => {
        this.tabKey = tabKey;
        this.params = {};
    }

    @action
    saveRemindConf = (id) => {
        Apis.saveRemindConf({ id: id }).then(data => {
            this.receivecof = "1";
        });
    }
}